<extend name="Users:layout" />
<block name="content">
<style type="text/css">
.wst-pagination{
  margin-top: 10px;
  text-align: center;
  height: 25px;
  line-height: 25px;
}
.wst-current{
  background-color: rgb(226, 62, 61);
  color: #fff;
  padding: 0 12px;
  border-radius: 2px;
  height: 26px;
  line-height: 26px;
  display: inline-block;
  vertical-align: top;
  font-size: 12px;
}
.wst-num{
  background-color: #f1eff0;
  padding: 0 12px;
  border-radius: 2px; 
  margin: 0 3px 6px;
  height: 26px;
  line-height: 26px;
  text-decoration: none;
  color: #666;
  display: inline-block;
  vertical-align: top;
  font-size: 12px;
}
.wst-next,.wst-prev{
  background-color: #f1eff0;
  padding: 0 12px;
  border-radius: 2px;

  height: 26px;
  line-height: 26px;
  text-decoration: none;
  color: #666;
  display: inline-block;
  vertical-align: top;
  font-size: 12px;
}

</style>
<script type="text/javascript">
    function del_user_youhui(youhui_id,user_id){
  layer.confirm("您确定要删除该优惠券？",{icon: 3, title:'系统提示'},function(tips){
    $.post(Think.U('Home/Youhui/del_user_youhui'),{youhui_id:youhui_id,user_id:user_id},function(data,textStatus){
      layer.close(tips);
        var json = WST.toJson(data);
        if(json.status=='1'){
          WST.msg('操作成功！', {icon: 1},function(){
            location.reload();
          });
        }else{
          WST.msg('操作失败', {icon: 5});
        }
    });
  });
}

function del_use_record(id){
  layer.confirm("您确定要删除该优惠券使用记录吗？",{icon: 3, title:'系统提示'},function(tips){
    $.post(Think.U('Home/Youhui/del_use_record'),{id:id},function(data,textStatus){
      layer.close(tips);
        var json = WST.toJson(data);
        if(json.status=='1'){
          WST.msg('操作成功！', {icon: 1},function(){
            location.reload();
          });
        }else{
          WST.msg('操作失败', {icon: 5});
        }
    });
  });
}

</script>
    <div class="wst-body"> 
       <div class='wst-page-header'>买家中心 > 我的优惠券</div>
       <div class='wst-page-content'>
       <button class="wst-btn-query" onclick="javascript:window.location.href='/Home/Youhui/userlist.html?type=1'">未使用</button>
       <button class="wst-btn-query" onclick="javascript:window.location.href='/Home/Youhui/userlist.html?type=2'">已使用</button>
       <button class="wst-btn-query" onclick="javascript:window.location.href='/Home/Youhui/userlist.html?type=3'">已失效</button>
       <?php if(empty($ture)){ ?>
        <table class='wst-list' style="font-size:13px;text-align: center;">
           <thead>
             <tr>
               <th width='80'>优惠券序号</th>
               <th width='*'>优惠券名称</th>
               <th>剩余张数</th>
               <th>优惠券所属商家</th>
               <th>使用范围</th>
               <th>优惠券属性</th>
               <th>折扣/优惠额度</th>
               <th>所需消费金额</th>
               <th>有效时间</th>
               <th>操作</th>
             </tr>
           </thead>
           <tbody>
            <volist name='list' id='vo'>
            <tr >
            <td>{$vo['youhui_id']}</td>
            <td>{$vo['name']}</td>
            <td>{$vo['surplus']}</td>
            <td><a href="/Home/Shops/toShopHome/shopId/{$vo['supplier_id']}.html">{$vo['supplier_name']}</a></td>
            <td><switch name="vo['youhui_scope']" >
             <case value="1">全店可用</case>
             <case value="2">部分分类</case>
             <case value="3">部分商品</case>
             <case value="4">部分品牌分类</case>
             <case value="5">部分商城分类</case>
             </switch></td>
            <td>
       <switch name="vo['youhui_type']" >
             <case value="0"><span class="type">减免券</case>
             <case value="1"><span class="type">折扣券</case>
             </switch></td>
            <td>
             <switch name="vo['youhui_type']" >
             <case value="0">{$vo['breaks_menoy']}元</case>
             <case value="1">{$vo['breaks_menoy']}折</case>
             </switch></td>
            <td>{$vo['total_fee']}元</td>
            <td align="center">
            {$vo['begin_time']|date='Y-m-d H:i',###}
            <p style="display: block; line-height: 10px;">/</p>
            {$vo['end_time']|date='Y-m-d H:i',###}
            </td>
            <td>
            <if condition="($vo['u_is_effect']) eq 1">
            <a href="/Home/Shops/toShopHome/shopId/{$vo['supplier_id']}.html">[进入店铺]</a>|</if>
            <a style="cursor: pointer;" onclick="javascript:del_user_youhui({$vo['youhui_id']},{$vo['user_id']})" >[删除]</a></td>
      </tr>
            </volist>
            <tr>
             <td colspan='10' class="nav_down" >{$show}</td>
           </tr>
           </tbody>
        </table>
           <?php }else{ ?>
        <table class='wst-list' style="font-size:13px;text-align: center;">
           <thead>
             <tr>
               <th width='80'>序号</th>
               <th width='*'>优惠券名称</th>
               <th>优惠券所属商家</th>
               <th>减免金额</th>
               <th>使用时间</th>
               <th>操作</th>
             </tr>
           </thead>
           <tbody>
            <volist name='list' id='vo'>
            <tr >
            <td>{$vo['id']}</td>
            <td>{$vo['name']}</td>
            <td><a href="/Home/Shops/toShopHome/shopId/{$vo['shopId']}.html">{$vo['shopName']}</a></td>
            <td>{$vo['money']}元</td>
            <td>
            {$vo['useTime']|date='Y-m-d H:i',###}
            </td>
            <td>
            <a style="cursor: pointer;" onclick="javascript:del_use_record({$vo['id']})" >[删除]</a></td>
      </tr>
            </volist>
            <tr>
             <td colspan='6' class="nav_down" >{$show}</td>
           </tr>
           </tbody>
        </table>
           <?php } ?>
        </div>
    </div>
    
</block> 